package leetcode.f1t100;

import leetcode.struct.TreeNode;

/**
 * 判断两个二叉树是否一致
 * https://leetcode.com/problems/same-tree/
 *
 * @author lichx
 * @createTime 2024/2/22 15:19
 */
public class Q100_SameTree {

    public boolean isSameTree(TreeNode p, TreeNode q) {
        if(p == null && q == null) {
            return true;
        }
        if(p == null || q == null) {
            return false;
        }
        if(p.val != q.val){
            return false;
        }
        return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
    }
}
